using UnityEngine;

public class EffectUI : MonoBehaviour
{
	public Vector3 startpos;

	public Vector3 endpos;

	public bool showeffect;

	public Vector3 dir;

	public Transform moveeffect;

	public ParticleSystem particlesys;

	private int type;

	public float speed;

	private void Update()
	{
		if (!showeffect)
		{
			return;
		}
		moveeffect.transform.position = Vector3.Lerp(moveeffect.transform.position, endpos, Time.deltaTime * speed);
		if (Vector3.Distance(moveeffect.transform.position, endpos) < 0.02f)
		{
			disable();
			showeffect = false;
			if (type < 3)
			{
				MenuUIController.instance.uplineui.refershinfo();
			}
			else
			{
				MenuUIController.instance.rewardui.boxui.refershbox();
			}
		}
	}

	public void enable(Vector3 start, int effecttype)
	{
		if (!showeffect && GlobalInf.CurrentQuality >= Quality.Low)
		{
			type = effecttype;
			startpos = start;
			showeffect = true;
			moveeffect.position = start;
			particlesys.Clear();
			particlesys.Stop();
			UnityVersionUtil.SetActiveRecursive(moveeffect.gameObject, state: true);
			switch (effecttype)
			{
			case 0:
				endpos = MenuUIController.instance.uplineui.moneybtn.transform.position;
				break;
			case 1:
				endpos = MenuUIController.instance.uplineui.diamondbtn.transform.position;
				break;
			case 2:
				endpos = MenuUIController.instance.uplineui.energybtn.transform.position;
				break;
			case 3:
				endpos = MenuUIController.instance.rewardui.boxui.shownumlabel.transform.position;
				break;
			}
			dir = endpos - startpos;
			dir = dir.normalized;
			particlesys.Play();
		}
	}

	public void clear()
	{
		if (showeffect)
		{
			particlesys.Clear();
			particlesys.Stop();
		}
	}

	public void disable()
	{
		UnityVersionUtil.SetActiveRecursive(moveeffect.gameObject, state: false);
	}
}
